package com.ruoyi.framework.security.auth;

import java.util.HashMap;
import java.util.Map;

/**
 *	线程共享类
 * @author liuz
 */
public class RequestContext {


	//  private static final ThreadLocal<Map<String,Object>> threadLocal = new ThreadLocal<>();
	/*将父线程变量传递给子线程*/
	private static final InheritableThreadLocal<Map<String,Object>> threadLocal = new InheritableThreadLocal<>();

	public static void init(){
		Map<String ,Object> context = new HashMap<>();
		threadLocal.set(context);
	}
	public static void set(String key ,Object value){
		Map<String,Object> map = (threadLocal.get());
		map.put(key ,value);

	}

	public static Object get(String key){
		return (threadLocal.get()).get(key);
	}

	public static ThreadLocal<Map<String, Object>> getThreadLocal() {
		return threadLocal;
	}
}
